import Vue from "vue"
import { createApp } from "./app"

const { app, router, store } = createApp()

if(window.__INITIAL_STATE__) {
    store.replaceState(window.__INITIAL_STATE__)
}

Vue.mixin({
    beforeMount() {
        const { asyncData } = this.$options
        if(asyncData) {
            // 将获取数组操作分配给promise
            // 以便在组件中，我们可以在数据准备就绪后
            // 通过运行`this.dataPromise.then()`来执行其他任务
            this.dataPromise = asyncData({
                store: this.$store,
                route: this.$route
            })
        }
    }
})

router.onReady(() => {
    app.$mount("#app")
})

